from selenium.webdriver.common.keys import Keys

from baiduspider.db.mongodb import mongodb
from baiduspider.model.wordItem import wordItem
from selenuim.seleniumCrawlsTool import seleniumCrawlsTool


class hanyu():
    url = 'http://xh.5156edu.com/'

    def daici(self):
        link = sl.getElementByLinkText('代词')
        link.click()
        renchens = sl.getElement(value='table19').text
        renchens = str(renchens).replace('\n', ' ').split(' ')
        for word in renchens:
            b = wordItem()
            b.word = word
            b.cixing = '人称代词'
            print(b.word)
            mongodb.save(b)
        zhishi = sl.getElement(value='table20').text
        zhishi = str(zhishi).replace('\n', ' ').split(' ')
        for word in zhishi:
            b = wordItem()
            b.word = word
            b.cixing = '指示代词'
            if b.word == '指近' or b.word == '指远' or b.word == '其他':
                continue
            print(b.word)
            mongodb.save(b)

if __name__ == '__main__':


    # sl = seleniumCrawlsTool(hanyu.url)
    # link = sl.getElementByLinkText('量词')
    # link.click()
    words='如果……就…… 假使……便…… 要是……那么……'.split(" ")
    for i in words:
        b = wordItem()
        b.word = i
        b.colname='guanlianci'
        b.cixing = '假设关系'
        mongodb.save(b)
    # sl.close()